package com.example.customeview;

import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.customeview.widget.MyRecyclerView;
import com.example.customeview.widget.MySlideRecyclerView;

import java.util.ArrayList;

public class RecyclerViewTest extends AppCompatActivity {
    private static final String TAG = "RecyclerViewTest";
    private MyRecyclerView viewById;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        initview();
        ImageView imageView = new ImageView(RecyclerViewTest.this);

    }

    private void initview() {
        viewById = findViewById(R.id.my_recycler);
        initRecyler();
    }

    private void initRecyler() {
        ArrayList<String> strings = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            String s = new StringBuilder("这是第").append(i).append("个item").toString();
            strings.add(s);
        }
        viewById.setLayoutManager(new LinearLayoutManager(this,
                LinearLayoutManager.VERTICAL, false));
        viewById.setAdapter(new MyRecyclerViewAdapter(strings, RecyclerViewTest.this));
        viewById.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
                outRect.top = 4;
            }
        });
    }
}




